/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.StructuredActivities;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.Kernel.ValueSpecification;
import edu.pku.sei.modeler.model.uml.Kernel.ValueSpecification;
import edu.pku.sei.modeler.model.uml.InternalStructures.ConnectorEnd;

import edu.pku.sei.modeler.model.uml.Kernel.TypedElement;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Variable extends TypedElement implements IVariable {
	// attributes
	
	
	
	protected boolean isOrdered;
	
	protected boolean isUnique;
	
	protected int upper;
	
	protected int lower;
	
	
	// references
	
	
	
	protected MetaTypedList upperValue;
	
	protected MetaTypedList lowerValue;
	
	protected MetaTypedList end;
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "VARIABLE_ISORDERED",
			catalog = "Model",
			name = ModelPackage.MULTIPLICITYELEMENT_ISORDERED,
			setter = "setisOrdered"
			)
	
	public boolean getIsOrdered() {
		return isOrdered;
	}
	public void setIsOrdered(boolean newIsOrdered) {
		boolean oldisOrdered = isOrdered;
		isOrdered = newIsOrdered;
		firePropertyChange(ModelPackage.MULTIPLICITYELEMENT_ISORDERED, oldisOrdered, newIsOrdered);
	}
	
	@MethodProperty(
			id = "VARIABLE_ISUNIQUE",
			catalog = "Model",
			name = ModelPackage.MULTIPLICITYELEMENT_ISUNIQUE,
			setter = "setisUnique"
			)
	
	public boolean getIsUnique() {
		return isUnique;
	}
	public void setIsUnique(boolean newIsUnique) {
		boolean oldisUnique = isUnique;
		isUnique = newIsUnique;
		firePropertyChange(ModelPackage.MULTIPLICITYELEMENT_ISUNIQUE, oldisUnique, newIsUnique);
	}
	
	@MethodProperty(
			id = "VARIABLE_UPPER",
			catalog = "Model",
			name = ModelPackage.MULTIPLICITYELEMENT_UPPER,
			setter = "setupper"
			)
	
	public int getUpper() {
		return upper;
	}
	public void setUpper(int newUpper) {
		int oldupper = upper;
		upper = newUpper;
		firePropertyChange(ModelPackage.MULTIPLICITYELEMENT_UPPER, oldupper, newUpper);
	}
	
	@MethodProperty(
			id = "VARIABLE_LOWER",
			catalog = "Model",
			name = ModelPackage.MULTIPLICITYELEMENT_LOWER,
			setter = "setlower"
			)
	
	public int getLower() {
		return lower;
	}
	public void setLower(int newLower) {
		int oldlower = lower;
		lower = newLower;
		firePropertyChange(ModelPackage.MULTIPLICITYELEMENT_LOWER, oldlower, newLower);
	}
	
	// getters for references
	
	public MetaTypedList getUpperValue() {
		if(upperValue == null) {
			upperValue = new MetaTypedList(ValueSpecification.class, this, ModelPackage.MULTIPLICITYELEMENT_UPPERVALUE);
		}
		return upperValue;
	}
	
	public MetaTypedList getLowerValue() {
		if(lowerValue == null) {
			lowerValue = new MetaTypedList(ValueSpecification.class, this, ModelPackage.MULTIPLICITYELEMENT_LOWERVALUE);
		}
		return lowerValue;
	}
	
	public MetaTypedList getEnd() {
		if(end == null) {
			end = new MetaTypedList(ConnectorEnd.class, this, ModelPackage.CONNECTABLEELEMENT_END);
		}
		return end;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.MULTIPLICITYELEMENT_ISORDERED, isOrdered);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.MULTIPLICITYELEMENT_ISUNIQUE, isUnique);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.MULTIPLICITYELEMENT_UPPER, upper);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.MULTIPLICITYELEMENT_LOWER, lower);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.MULTIPLICITYELEMENT_UPPERVALUE, upperValue);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.MULTIPLICITYELEMENT_LOWERVALUE, lowerValue);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.CONNECTABLEELEMENT_END, end);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		isOrdered = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.MULTIPLICITYELEMENT_ISORDERED);
		
		isUnique = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.MULTIPLICITYELEMENT_ISUNIQUE);
		
		upper = XMLUtility.xmlInstance.deSerializeInt(root, ModelPackage.MULTIPLICITYELEMENT_UPPER);
		
		lower = XMLUtility.xmlInstance.deSerializeInt(root, ModelPackage.MULTIPLICITYELEMENT_LOWER);
		
		// references
		
		this.getUpperValue().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.MULTIPLICITYELEMENT_UPPERVALUE));
		
		this.getLowerValue().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.MULTIPLICITYELEMENT_LOWERVALUE));
		
		this.getEnd().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.CONNECTABLEELEMENT_END, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.CONNECTABLEELEMENT_END.equals(featureID)) {
			getEnd().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 